﻿using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Acme.MyProject.Localization;
using Acme.MyProject.MultiTenancy;
using Microsoft.SqlServer.Server;
using Nest;
using Volo.Abp.Identity.Web.Navigation;
using Volo.Abp.SettingManagement.Web.Navigation;
using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation;

namespace Acme.MyProject.Web.Menus;

public class MyProjectMenuContributor : IMenuContributor
{
    public async Task ConfigureMenuAsync(MenuConfigurationContext context)
    {
        if (context.Menu.Name == StandardMenus.Main)
        {
            await ConfigureMainMenuAsync(context);
        }
    }

    private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
    {
        var administration = context.Menu.GetAdministration();
        var l = context.GetLocalizer<MyProjectResource>();

        context.Menu.Items.Insert(0, new ApplicationMenuItem(MyProjectMenus.Home, l["Menu:Home"], "~/", icon: "fas fa-home", order: 0));


        context.Menu.Items.Add(new ApplicationMenuItem("MyProject.Docs", l["Menu:Docs"], "/Documents", icon: "fa-dochub", order: 1));

     //INSERT[dbo].[DocsProjects]([Id], [Name], [ShortName], [Format], [DefaultDocumentName], [NavigationDocumentName],
     //[MinimumVersion], [DocumentStoreType], [ExtraProperties], [MainWebsiteUrl], [LatestVersionBranchName], [ParametersDocumentName], [ConcurrencyStamp])
     //VALUES(N'12f21123-e08e-4f15-bedb-ae0b2d939659', N'ABP framework (FileSystem)', N'abp', N'md', N'Index', N'docs-nav.json', NULL, N'FileSystem', N'{"Path":"F:\\abp-8.2.0\\docs"}', N'/', NULL, N'', '0x00000000001135D3')



        if (MultiTenancyConsts.IsEnabled)
        {
            administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
        }
        else
        {
            administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
        }

        administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
        administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3);

        return Task.CompletedTask;
    }
}
